﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics.Contracts;
using FazaDemo.BL.InterfaceDomain;
using FazaDemo.BL.SubDomains;

namespace FazaDemo.BL.Factories
{
    [ContractClassFor(typeof(INavCondElemFactory))]
    abstract class NavCondElemFactoryContract : INavCondElemFactory
    {

        private const int DefParamsCount = 13;

        private readonly List<string> _fieldTypes = new List<string> {"N", "C", "D", "F", "B", "M"};

        private readonly List<string> _isShowViews = new List<string> {"ShowView", "NoShowView"};

        private readonly List<string> _orderStates = new List<string> {"Order", "NoOrder"};

        private readonly List<string> _isSpravs = new List<string> {"Sprav", "NoSprav"};

        private const string NoEcq = "NoECQ";

        private readonly List<string> _isOuts = new List<string> {"Out", "NoOut"};

        private readonly List<string> _isKeyFields = new List<string> {"KeyField", "NoKeyField"};

        private readonly List<string> _isFontBolds = new List<string> {"FontBold", "NoFontBold"};

        public NavCondElement GetNavCondElement(IList<string> fieldParams)
        {
            Contract.Requires(fieldParams != null);
            Contract.Requires(fieldParams.Count == DefParamsCount);
            Contract.Requires(_fieldTypes.Contains(fieldParams[2]));
            Contract.Requires(_isShowViews.Contains(fieldParams[5]));
            Contract.Requires(_orderStates.Contains(fieldParams[7]));
            Contract.Requires(_isSpravs.Contains(fieldParams[8]));
            Contract.Requires(fieldParams[9] == NoEcq || fieldParams[9].All(Char.IsDigit));
            Contract.Requires(_isOuts.Contains(fieldParams[10]));
            Contract.Requires(_isKeyFields.Contains(fieldParams[11]));
            Contract.Requires(_isFontBolds.Contains(fieldParams[12]));
            Contract.Ensures(Contract.Result<NavCondElement>().ElemText != null);
            Contract.Ensures(Contract.Result<NavCondElement>().ElemText.Any());
            return default(NavCondElement);
        }
    }
}
